Add @implements to SPL iterator stubs#5672
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
| * @template-covariant TKey | ||
| * @template-covariant TValue | ||
| * @template TIterator of \RecursiveIterator<TKey, TValue>|\IteratorAggregate<TKey, TValue> |
There was a problem hiding this comment.
Does it means that RecursiveIteratorIterator has now three template like
RecursiveIteratorIterator<int, int, IteratorAggregate<int, int>>
if so, it will break code where people used the single-template RecursiveIteratorIterator no ?
Also, this won't be compatible with the stub from psalm
https://github.com/vimeo/psalm/blob/ca151242c84d8962b921bf59c509b49362ce0eec/stubs/CoreGenericIterators.phpstub#L902-L903
There was a problem hiding this comment.
You are right, this introduces a breaking change.
I revised my code.
Probably CI errors are not related I guess...
| $this->analyse([__DIR__ . '/data/bug-3425.php'], [ | ||
| [ | ||
| 'Parameter #1 $iterator of class RecursiveIteratorIterator constructor expects T of IteratorAggregate|RecursiveIterator, Generator<int, int, mixed, void> given.', | ||
| 'Parameter #1 $iterator of class RecursiveIteratorIterator constructor expects TIterator of IteratorAggregate|RecursiveIterator, Generator<int, int, mixed, void> given.', |
There was a problem hiding this comment.
You can avoid this change by not renaming the template from T to TIterator
This PR adds
@implementannotations to the stub of three classes:RecursiveIteratorIteratorDirectoryIteratorRecursiveDirectoryIteratorCloses phpstan/phpstan#8435